<%--
Created by IntelliJ IDEA.
User: SongTiantian
Date: 2020/11/18
Time: 17:33
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%@include file="/front-end/views/common/head.jsp"%>
    <title>影片详情</title>
    <style>
        *{
            margin:0;
            padding:0;
            list-style: none;
            text-decoration: none;
        }
        #head{
            width:100%;
            height:100px;
            background-color: #e5e5e5;
        }
        #head li{
            margin-top: 40px;
            float:left;
            height:39px;
            line-height: 39px;
            padding:0 20px;
            text-align:center;
            cursor:pointer;
            list-style: none;
            font-size: 30px;
        }
        #head img{
            float:left;
            height:100px;
        }
        #main{
            /* background-color: red; */
            width:100%;
            height:1200px;
        }
        .current{
            background-color: #c81623;
            color:#fff;
        }
        .item{
            display:none;
        }
        #guanying{
        overflow: hidden;
        width:1300px;
        height:900px;
        margin:0 auto;
        /* background-color: green; */
        }
        #guanying li{
            margin-top: 10px;
            float:left;
            height:39px;
            line-height: 39px;
            padding:0 20px;
            text-align:center;
            cursor:pointer;
            list-style: none;
            font-size: 25px;
        }
        .itemthree{
            margin:0 auto;
            margin-top:70px;
            width:1300px;
            height:515px;
            /* background-color: pink; */
        }
        #ccover{
            width: 220px;
            color:white;
            height: 310px;
            background-color:black;
            opacity: .6;
            margin-top: -250px;
            /* border-radius: 50%; */
        }
        #ccover h1{
            text-align: center;
            line-height: 280px;
            font-size: 50px;

        }
        .yying{
            position: relative;
            overflow: hidden;
            width: 220px;
            height: 300px;
            float:left;
            margin:20px;
            background-color: #e5e5e5;
        }
        .yying #top{
            /* float: left; */
            width: 220px;
            height:240px;
            background-color: red;
        }
        .yying #bottom{
            width: 220px;
            height:6px;
            /* float:left; */
            background-color: pink;
        }
        .yying img{
       
            width: 220px;
            height:240px;
        }
        .yying input{
            /* position: absolute; */
            /* z-index:999; */
            border: 1px solid #eb002a;
            width: 220px;
            height:60px;
            font-size: 20px;
            background-color: #eb002a;
            color:white;
            cursor: pointer;
        }
        #xiang-left{
            float:left;
            width:40%;
            height:600px;
            /* background-color: green; */
        }
        #xiang-left img{
            width:75%;
        }
        #xiang-right{
            float:left;
            width: 60%;
            height:600px;
            /* background-color: red; */
        }
        #xiang-right h1{
            margin-bottom:50px;
            font-size:50px;
        }
        #xiang-right p{
            font-size: 20px;
            margin-right:50px;
        }
        #yingyuan{
            background-color: #FFF6F5;
            margin-top: 30px;
            height:300px;
        }
        #tuipiao{
            float: left;
            background-color: #eb002a;
            border:2px solid #eb002a;
            color:white;
            margin-top:100px;
            margin-left:300px;
            width: 150px;
            height: 60px;
            font-size:25px;
        }
        #fanhui{
            float: left;
            background-color: #eb002a;
            border:2px solid #eb002a;
            color:white;
            margin-top:-58px;
            margin-left:550px;
            width: 150px;
            height: 60px;
            font-size:25px;
        }
    </style>
</head>
<body>
    <div id="head">
        <img src="front-end/img/logo.png" alt="">
    </div>
    <div id="main">
        <div class="item" style="display:block;">
            <div id="guanying">
                <div class="itemthree" style="display:block;background-color: #e5e5e5;">
                    <div id="xiang-left">
                        <img src="${requestScope.play.play_image}" alt="">
                    </div>
                    <div id="xiang-right">
                        <h1>${requestScope.play.play_name}</h1>
                        <p>票价： ${requestScope.play.play_ticket_price}</p>
                        <p>类型：${requestScope.playTypes[play.play_type_id].play_type_name}</p>
                        <p>语言：${requestScope.playLangs[play.play_lang_id].play_lang_name}</p>
                        <p>片长：${requestScope.play.play_length}</p>
                        <p>剧情介绍：${requestScope.play.play_introduction}</p>
                        <button id="tuipiao">点击退票</button>
                        <button id="fanhui">
                            <a href="index.jsp" style="color:white;">返回首页</a>
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script>
    var tuipiao = document.getElementById('tuipiao');
    tuipiao.addEventListener('click',function(){

        var xmlhttprequest = new XMLHttpRequest();
        var url = "user/indexServlet?action=refund&sched_id=${requestScope.schedule.sched_id}&user_id=${sessionScope.user.id}&ticket_id=${requestScope.ticket.ticket_id}";
        xmlhttprequest.open("POST",url,true);
        xmlhttprequest.onreadystatechange = function(){
            if (xmlhttprequest.readyState == 4 && xmlhttprequest.status == 200) {
                var data = JSON.parse(xmlhttprequest.responseText);
                alert(data);
                window.location.href="user/indexServlet?action=myOrder";
            }
        }
        xmlhttprequest.send();
    })
    var lis = document.getElementById('head').querySelectorAll('li');
        var items = document.getElementById('main').querySelectorAll('.item');

        for(var i = 0;i<lis.length;i++){
            lis[i].setAttribute('index',i);
            lis[i].onclick = function (){
                for(var i =0;i<lis.length;i++){
                    lis[i].className = '';
                }
                this.className = 'current';
                var index = this.getAttribute('index');
                for(var i = 0;i<items.length;i++){
                    items[i].style.display = 'none';
                }
                items[index].style.display = 'block';
            }
        }
        window.addEventListener('load',function(){
        var box = document.querySelector('#lunbotu');
        var ul = box.querySelector('ul');
        var uli = box.querySelectorAll('li');
        var img = document.querySelector('img');
        var ol = document.querySelector('ol');
        var left = document.querySelector('#left');
        var right = document.querySelector('#right');
        var boxWidth = box.offsetWidth;


        //box
        box.addEventListener('mouseenter',function(){
            left.style.display = 'block';
            right.style.display = 'block';
            clearInterval(timer);
        })
        box.addEventListener('mouseleave',function(){
            left.style.display = 'none';
            right.style.display = 'none';
            timer = setInterval(function(){
                right.click();
            },2000);
        })
        


        //小圈圈
        for(var i = 0;i<uli.length;i++){
            var oli = document.createElement('li');
            ol.appendChild(oli);
            oli.setAttribute('index',i);
            oli.addEventListener('click',function(){
                for(var i = 0;i<ol.children.length;i++){
                    ol.children[i].className='';
                }
                this.className = 'current';

                var index = this.getAttribute('index');
                circle = index;
                num = index;
                animate(ul,-index*boxWidth);
            })
        }
        ol.children[0].className = 'current';
        var first = ul.children[0].cloneNode(true);
        ul.appendChild(first);


        //左右键
        var num = 0;
        var circle = 0;
        right.addEventListener('click',function(){
            if(num ==ul.children.length-1){
                ul.style.left = 0;
                num = 0;
            }
            num++;
            animate(ul,-num * boxWidth);


            circle++;
            if(circle == ul.children.length-1){
                circle =0;
            }
            for(var i = 0;i<ol.children.length;i++){
                ol.children[i].className = '';
            }
            ol.children[circle].className='current';
            
            
        })
        left.addEventListener('click',function(){
            if(num == 0){
                ul.style.left = (ul.children.length-1)*boxWidth;
            }
            num--;

            circle--;
            if(circle <0){
                circle = ol.children.length -1;
            }
            for(var i = 0;i<ol.children.length;i++){
                ol.children[i].className = '';
            }
            ol.children[circle].className='current';
            animate(ul,-num*boxWidth);
        })
        var timer = setInterval(function(){
            right.click();
        },8000)



        function animate(obj,target){
            clearInterval(obj.timer);
            obj.timer = setInterval(function(){
                var step = (target - obj.offsetLeft) / 10;
                step = step > 0? Math.ceil(step) : Math.floor(step);
                if(obj.offsetLeft == target){
                    clearInterval(obj.timer);
                }     
            obj.style.left = obj.offsetLeft + step + 'px';
            },20); 
        }



    })

    var dianying = document.querySelector('#dianying');
    var li = dianying.querySelectorAll('li');
    var itemone = document.querySelectorAll('.itemone');
    for(var i = 0;i<li.length;i++){
            li[i].setAttribute('index',i);
            li[i].onclick = function (){
                for(var i =0;i<li.length;i++){
                    li[i].className = '';
                }
                this.className = 'currentt';
                var index = this.getAttribute('index');
                for(var i = 0;i<itemone.length;i++){
                   itemone[i].style.display = 'none';
                }
               itemone[index].style.display = 'block';
            }
        }
        var guanying = document.querySelector('#guanying');
        var lili = guanying.querySelectorAll('li');
        var itemthree = document.querySelectorAll('.itemthree');
        for(var i = 0;i<lili.length;i++){
                lili[i].setAttribute('index',i);
                lili[i].onclick = function (){
                    for(var i =0;i<lili.length;i++){
                        lili[i].className = '';
                    }
                    this.className = 'currentt';
                    var index = this.getAttribute('index');
                    for(var i = 0;i<itemthree.length;i++){
                    itemthree[i].style.display = 'none';
                    }
                itemthree[index].style.display = 'block';
                }
            }

</script>
</html>